#ifndef CLIENT_MAIN_H
#define CLIENT_MAIN_H

#include <QWidget>
#include <QThread>
#include "message.h"
#include "device_console.h"
#include "tcp_thread.h"
#include <QRegExp>
#include <QRegExpValidator>
namespace Ui {
class Client_Main;
}
class Device_Console;
class TCP_Thread;
class Client_Main : public QWidget
{
    Q_OBJECT

public:
    explicit Client_Main(QWidget *parent = 0);
    ~Client_Main();

private slots:

    void ConsoleLogout();//注销槽函数
    void RecvUserMsg(QVariant v_msg);//接受userServer数据包
    void on_userNameLineEdit_textChanged(const QString &arg1);
    void on_passwdLineEdit_textChanged(const QString &arg1);
    void on_logInPushButton_clicked();
    void on_registerPushButton_clicked();

signals:
    void s_sendMsg(QVariant v_msg);
    void s_closeSockfd();
    void s_connectSockfd(QString ip,qint16 port);

private:
    Ui::Client_Main *ui;
    Device_Console *device_Console = nullptr;
    TCP_Thread *user_TCP =nullptr;
    char g_cUserName[NAME_PASSWORD_LEN] = {0};
    void WrongBox(QString title,QString word);
    void LoginConsole();//登陆进入控制台
    void TakeLoginMsg(MsgStruct msg);//分析服务器返回的登陆结果
    void TakeRegisterMsg(MsgStruct msg);//分析服务器返回的注册结果


protected:
    //关闭事件
    virtual void closeEvent(QCloseEvent *event);

};


#endif // CLIENT_MAIN_H
